using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Spread.Common.Features.Sample;
using FarPoint.Win;
using FarPoint.Win.Spread;
using FarPoint.Win.Spread.CellType;
using FarPoint.Win.Spread.Design;
using FarPoint.Win.Spread.Model;

namespace Spread.Worksheet.Features
{
    public partial class BordersDemo : BaseSampleControl
    {
        ComplexBorderSideStyle[] LineStyleArray = new ComplexBorderSideStyle[] { ComplexBorderSideStyle.DashDotDot, ComplexBorderSideStyle.MediumLine, ComplexBorderSideStyle.ThinLine, ComplexBorderSideStyle.DoubleLine };
        Color[] ColorArray = new Color[] { Color.Red, Color.Green, Color.Blue, Color.Black };
        public BordersDemo()
        {
            InitializeComponent();
            InitializeControls();
            SetupSpreadSheet();
        }
        private void InitializeControls()
        {
            Name = "Borders and GridLines";
            borderStyleComboBox.DataSource = Enum.GetValues(typeof(ComplexBorderSideStyle));

            System.Reflection.PropertyInfo[] _properties = typeof(Color).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
            foreach(System.Reflection.PropertyInfo _property in _properties)
            {
                borderColorComboBox.Items.Add(_property.Name);
                gridLineColorComboBox.Items.Add(_property.Name);
            }
            borderColorComboBox.SelectedIndex = 0;
            gridLineColorComboBox.SelectedItem = spread.ActiveSheet.VerticalGridLine.Color.ToKnownColor().ToString();

            int[] _textRotationArray = { 0, 30, 45, 60, 90 };
            textRotationComboBox.DataSource = _textRotationArray;
            textRotationComboBox.SelectedIndex = -1;
            textRotationComboBox.DropDownStyle = ComboBoxStyle.DropDownList;

            diagonalLineCKB.Checked = true;
            gridLineCKB.Checked = true;
        }
        private void SetupSpreadSheet()
        {
            spread.ActiveSheet = spread.Sheets[0];
            int index = 0;
            int count = 0;
            for (int row = 1; row <= 10; row = row + 3)
            {
                count = 0;
                for (int _row = row; _row <= row+1; _row++)
                {
                    for (int _column = 1; _column <= 2; _column++)
                    {
                        SetBorder(sheetView.Cells[_row, _column], new ComplexBorderSide(GetBorderLineStyle(index), GetColor(index+count)));
                        count++;
                    }
                }
                index++;
            }
            SetCellsBorder(new Cell[] { sheetView.Cells[1, 4], sheetView.Cells[1, 5], sheetView.Cells[2, 4], sheetView.Cells[2, 5] }, 0);
            SetCellsBorder(new Cell[] { sheetView.Cells[4, 4], sheetView.Cells[4, 5], sheetView.Cells[5, 4], sheetView.Cells[5, 5] }, 1);
            SetCellsBorder(new Cell[] { sheetView.Cells[7, 4], sheetView.Cells[7, 5], sheetView.Cells[8, 4], sheetView.Cells[8, 5] }, 2);
            SetCellsBorder(new Cell[] { sheetView.Cells[10, 4], sheetView.Cells[10, 5], sheetView.Cells[11, 4], sheetView.Cells[11, 5] }, 3);

            index = 0;
            for(int row = 1; row <= 10; row=row+3)
            {
                count = 0;
                for(int _row = row; _row <= row + 1; _row++)
                {
                    for(int _column = 7; _column <= 8; _column++)
                    {
                        SetCellBorder(sheetView.Cells[_row, _column], index +count);
                        count++;
                    }
                }
                index++;
            }

            int rowIndex = 14;
            sheetView.Cells[rowIndex, 2].RowSpan = 5;
            sheetView.Cells[rowIndex, 2].ColumnSpan = 6;
            sheetView.Cells[rowIndex, 2].Border = new ComplexBorder(new ComplexBorderSide(ComplexBorderSideStyle.DashDot, Color.Purple));
            SetMergeCellBorder(rowIndex);
            
            rowIndex += 8;
            sheetView.Cells[rowIndex, 2].RowSpan = 5;
            sheetView.Cells[rowIndex, 2].ColumnSpan = 6;
            sheetView.Cells[rowIndex, 2].Border = new ComplexBorder(new ComplexBorderSide(ComplexBorderSideStyle.DoubleLine, Color.Purple));
            SetMergeCellBorder(rowIndex);

            rowIndex += 8;
            sheetView.Cells[rowIndex, 2].RowSpan = 5;
            sheetView.Cells[rowIndex, 2].ColumnSpan = 6;
            sheetView.Cells[rowIndex, 2].Border = new ComplexBorder(new ComplexBorderSide(ComplexBorderSideStyle.ThickLine, Color.Purple));
            SetMergeCellBorder(rowIndex);

            rowIndex += 8;
            sheetView.Cells[rowIndex, 2].RowSpan = 5;
            sheetView.Cells[rowIndex, 2].ColumnSpan = 6;
            sheetView.Cells[rowIndex, 2].Border = new ComplexBorder(new ComplexBorderSide(ComplexBorderSideStyle.MediumLine, Color.Purple));
            SetMergeCellBorder(rowIndex);

            SetBorder(sheetView.Cells[3, 3], new ComplexBorderSide(ComplexBorderSideStyle.MediumLine, Color.Black), true);
            SetBorder(sheetView.Cells[6, 3], new ComplexBorderSide(ComplexBorderSideStyle.MediumLine, Color.Black), true);
            SetBorder(sheetView.Cells[9, 3], new ComplexBorderSide(ComplexBorderSideStyle.MediumLine, Color.Black), true);
            SetBorder(sheetView.Cells[3, 6], new ComplexBorderSide(ComplexBorderSideStyle.MediumDashDot, Color.Black), true);
            SetBorder(sheetView.Cells[6, 6], new ComplexBorderSide(ComplexBorderSideStyle.MediumDashDotDot, Color.Black), true);
            SetBorder(sheetView.Cells[9, 6], new ComplexBorderSide(ComplexBorderSideStyle.MediumDashDot, Color.Black), true);

            int _count = LineStyleArray.Length;
            for(int _left = 0; _left < _count; _left++)
            {
                int _rows = 0;
                for(int _top = 0; _top < _count; _top++)
                {
                    for(int _right = 0; _right < _count; _right++)
                    {
                        for(int _bottom = 0; _bottom < _count; _bottom++)
                        {
                            sheetView.Cells[_rows,_left * 2 + 10].Border = _left == _count ? null : new ComplexBorder(new ComplexBorderSide(GetBorderLineStyle(_left), GetColor(_left)));
                            sheetView.Cells[_rows, _left * 2 + 11].Border = _top == _count ? null : new ComplexBorder(new ComplexBorderSide(GetBorderLineStyle(_top), GetColor(_top)));
                            sheetView.Cells[_rows, _left * 2 + 11].Border = _right == _count ? null : new ComplexBorder(new ComplexBorderSide(GetBorderLineStyle(_right), GetColor(_right)));
                            sheetView.Cells[_rows + 1, _left * 2 + 10].Border = _bottom == _count ? null : new ComplexBorder(new ComplexBorderSide(GetBorderLineStyle(_bottom), GetColor(_bottom)));
                            _rows += 2;
                        }
                    }
                }
            }

            secondSheetView.Rows[4].Height = 50;
            SetRotateText(secondSheetView.Cells[4, 2], "First Name", 45);
            SetRotateText(secondSheetView.Cells[4, 3], "Last Name", 45);
            SetRotateText(secondSheetView.Cells[4, 4], "Age", 45);
            SetRotateText(secondSheetView.Cells[4, 5], "Gender", 45);
            SetRotateText(secondSheetView.Cells[4, 6], "Score", 45);

            for(int _column = 2; _column < 7; _column++)
                SetBorder(secondSheetView.Cells[4, _column], new ComplexBorderSide(ComplexBorderSideStyle.MediumLine, Color.Black), true);
            

            secondSheetView.Cells[5, 2].Text = "John";
            secondSheetView.Cells[5, 3].Text = "Smith";
            secondSheetView.Cells[5, 4].Text = "18";
            secondSheetView.Cells[5, 5].Text = "Male";
            secondSheetView.Cells[5, 6].Text = "80";

            secondSheetView.Cells[6, 2].Text = "Micheal";
            secondSheetView.Cells[6, 3].Text = "Chang";
            secondSheetView.Cells[6, 4].Text = "21";
            secondSheetView.Cells[6, 5].Text = "Male";
            secondSheetView.Cells[6, 6].Text = "85";

            secondSheetView.Cells[7, 2].Text = "Jessica";
            secondSheetView.Cells[7, 3].Text = "Alba";
            secondSheetView.Cells[7, 4].Text = "23";
            secondSheetView.Cells[7, 5].Text = "Female";
            secondSheetView.Cells[7, 6].Text = "90";
        }
        private void DiagonalLineCKB_CheckedChanged(object sender, EventArgs e)
        {
            spread.ActiveSheet.EnableDiagonalLine = diagonalLineCKB.Checked;
        }

        private void SetGridLineButton_Click(object sender, EventArgs e)
        {
            if (gridLineCKB.Checked)
            {
                spread.ActiveSheet.VerticalGridLine = new GridLine(GridLineType.Flat, GetColor(gridLineColorComboBox.SelectedItem.ToString()));
                spread.ActiveSheet.HorizontalGridLine = new GridLine(GridLineType.Flat, GetColor(gridLineColorComboBox.SelectedItem.ToString()));
            }
            else
            {
                spread.ActiveSheet.VerticalGridLine = new GridLine(GridLineType.None, GetColor(gridLineColorComboBox.SelectedItem.ToString()));
                spread.ActiveSheet.HorizontalGridLine = new GridLine(GridLineType.None, GetColor(gridLineColorComboBox.SelectedItem.ToString()));
            }
            Console.WriteLine(gridLineColorComboBox.SelectedItem);
        }

        private void Spread_ActiveSheetChanged(object sender, EventArgs e)
        {
            gridLineCKB.Checked = spread.ActiveSheet.VerticalGridLine.Type != GridLineType.None;
            gridLineColorComboBox.SelectedItem = spread.ActiveSheet.VerticalGridLine.Color.ToKnownColor().ToString();
            diagonalLineCKB.Checked = spread.ActiveSheet.EnableDiagonalLine;
        }

        private void SetButton_Click(object sender, EventArgs e)
        {
            CellRange[] cellRanges = spread.ActiveSheet.GetSelections();
            foreach(CellRange cellRange in cellRanges)
            {
                CellRange range = GetActualCellRange(cellRange, spread.ActiveSheet.RowCount, spread.ActiveSheet.ColumnCount);
                for (int _row = range.Row; _row < range.Row + range.RowCount; _row++)
                {
                    for (int _column = range.Column; _column < range.Column + range.ColumnCount; _column++)
                    {
                        spread.ActiveSheet.Cells[_row, _column].Border = new ComplexBorder(new ComplexBorderSide((ComplexBorderSideStyle)borderStyleComboBox.SelectedItem, GetColor(borderColorComboBox.SelectedItem.ToString())));
                    }
                }
            }
        }
        private void TextRotationComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            CellRange[] cellRanges = spread.ActiveSheet.GetSelections();
            foreach(CellRange cellRange in cellRanges)
            {
                CellRange range = GetActualCellRange(cellRange, spread.ActiveSheet.RowCount, spread.ActiveSheet.ColumnCount);
                for(int _row = range.Row; _row < range.Row + range.RowCount; _row++)
                {
                    for(int _column = range.Column; _column < range.Column + range.ColumnCount; _column++)
                    {
                        TextCellType _textCell = new TextCellType();
                        _textCell.TextOrientation = TextOrientation.TextRotateCustom;
                        _textCell.TextRotationAngle = int.Parse(textRotationComboBox.SelectedItem.ToString());
                        spread.ActiveSheet.Cells[_row, _column].CellType = _textCell;
                    }
                }
            }
        }
        private void SetBorderButton_Click(object sender, EventArgs e)
        {
            ExternalDialogs.BorderEditor(spread);
        }

        private void _borderEditor_ApplyChanged(object sender, ApplyBorderEventArgs e)
        {
            CellRange[] cellRanges = spread.ActiveSheet.GetSelections();
            foreach (CellRange cellRange in cellRanges)
            {
                CellRange range = GetActualCellRange(cellRange, spread.ActiveSheet.RowCount, spread.ActiveSheet.ColumnCount);
                for (int _row = range.Row; _row < range.Row + range.RowCount; _row++)
                {
                    for (int _column = range.Column; _column < range.Column + range.ColumnCount; _column++)
                    {
                        spread.ActiveSheet.Cells[_row, _column].Border = e.Border;
                    }
                }
            }
        }

        private void ClearBorderButton_Click(object sender, EventArgs e)
        {
            SheetView _activeSheet = spread.ActiveSheet;
            CellRange[] _cellRanges = _activeSheet.GetSelections();
            foreach(CellRange _cellRange in _cellRanges)
            {
                CellRange _range = GetActualCellRange(_cellRange, _activeSheet.RowCount, _activeSheet.ColumnCount);
                for (int i = 0; i < _range.RowCount; i ++)
                {
                    for (int j = 0; j < _range.ColumnCount; j++)
                    {
                        SetBorder(_activeSheet.Cells[i + _range.Row, j + _range.Column], null);
                    }
                }
            }
        }

        private void SetRotateText(Cell _cell,string _text,int _angle)
        {
            TextCellType _textCellType = new TextCellType();
            _textCellType.TextOrientation = TextOrientation.TextRotateCustom;
            _textCellType.TextRotationAngle = _angle;
            _cell.CellType = _textCellType;
            _cell.Text = _text;
        }
        private void SetMergeCellBorder(int rowIndex)
        {
            SetBorder(sheetView.Cells[rowIndex - 1, 3], new ComplexBorderSide(ComplexBorderSideStyle.DashDotDot, Color.Red));
            SetBorder(sheetView.Cells[rowIndex - 1, 6], new ComplexBorderSide(ComplexBorderSideStyle.DoubleLine, Color.Green));
            SetBorder(sheetView.Cells[rowIndex + 1, 8], new ComplexBorderSide(ComplexBorderSideStyle.ThickLine, Color.Blue));
            SetBorder(sheetView.Cells[rowIndex + 3, 8], new ComplexBorderSide(ComplexBorderSideStyle.MediumLine, Color.Black));
            SetBorder(sheetView.Cells[rowIndex + 5, 6], new ComplexBorderSide(ComplexBorderSideStyle.MediumLine, Color.Red));
            SetBorder(sheetView.Cells[rowIndex + 5, 3], new ComplexBorderSide(ComplexBorderSideStyle.ThickLine, Color.Green));
            SetBorder(sheetView.Cells[rowIndex + 3, 1], new ComplexBorderSide(ComplexBorderSideStyle.DoubleLine, Color.Blue));
            SetBorder(sheetView.Cells[rowIndex + 1, 1], new ComplexBorderSide(ComplexBorderSideStyle.DashDotDot, Color.Black));
        }
        private Color GetColor(int index)
        {
            return ColorArray[index % ColorArray.Length];
        }
        private Color GetColor(string name)
        {
            return (Color)typeof(Color).GetProperty(name).GetValue(null, null);
        }
        private CellRange GetActualCellRange(CellRange cellRange, int rowCount, int columnCount)
        {
            if (cellRange.Row == -1 && cellRange.Column == -1)
            {
                return new CellRange(0, 0, rowCount, columnCount);
            }
            else if (cellRange.Row == -1)
            {
                return new CellRange(0, cellRange.Column, rowCount, cellRange.ColumnCount);
            }
            else if (cellRange.Column == -1)
            {
                return new CellRange(cellRange.Row, 0, cellRange.RowCount, columnCount);
            }

            return cellRange;
        }
        private ComplexBorderSideStyle GetBorderLineStyle(int index)
        {
            return LineStyleArray[index % LineStyleArray.Length];
        }
        private void SetCellsBorder(Cell[] cells,int index)
        {
            foreach(Cell cell in cells)
            {
                SetCellBorder(cell, index);
            }
        }
        private void SetCellBorder(Cell cell ,int index)
        {
            ComplexBorderSide left = new ComplexBorderSide(GetBorderLineStyle(index + 0), GetColor(index + 0));
            ComplexBorderSide top = new ComplexBorderSide(GetBorderLineStyle(index + 1), GetColor(index + 1));
            ComplexBorderSide right = new ComplexBorderSide(GetBorderLineStyle(index + 2), GetColor(index + 2));
            ComplexBorderSide bottom = new ComplexBorderSide(GetBorderLineStyle(index + 3), GetColor(index + 3));
            cell.Border = new ComplexBorder(left, top, right, bottom);
        }
        private void SetBorder(Cell _cell,ComplexBorderSide _border)
        {
            SetBorder(_cell, _border, false);
        }
        private void SetBorder(Cell _cell,ComplexBorderSide _border,bool _diagonalLine)
        {
            if (_border == null)
                _cell.ResetBorder();

            else
            {
                if (!_diagonalLine)
                    _cell.Border = new ComplexBorder(_border, _border, _border, _border);
                
                else
                    _cell.Border = new ComplexBorder(_border, _border, _border, _border, _border,true, true);
            }
        }
    }
}


//
//BordersDemo.Designer.cs
//


using FarPoint.Win.Spread;
namespace Spread.Worksheet.Features
{
    partial class BordersDemo
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.gridLinesGroupBox = new System.Windows.Forms.GroupBox();
            this.setGridLineButton = new System.Windows.Forms.Button();
            this.gridLineColorComboBox = new System.Windows.Forms.ComboBox();
            this.gridLineColorLabel = new System.Windows.Forms.Label();
            this.gridLineCKB = new System.Windows.Forms.CheckBox();
            this.textRotationGroupBox = new System.Windows.Forms.GroupBox();
            this.textRotationComboBox = new System.Windows.Forms.ComboBox();
            this.textRotationLabel = new System.Windows.Forms.Label();
            this.diagonalLineCKB = new System.Windows.Forms.CheckBox();
            this.quickSettingGroupBox = new System.Windows.Forms.GroupBox();
            this.setButton = new System.Windows.Forms.Button();
            this.borderColorComboBox = new System.Windows.Forms.ComboBox();
            this.borderColorLabel = new System.Windows.Forms.Label();
            this.borderStyleComboBox = new System.Windows.Forms.ComboBox();
            this.borderStyleLabel = new System.Windows.Forms.Label();
            this.clearBorderButton = new System.Windows.Forms.Button();
            this.setBorderButton = new System.Windows.Forms.Button();
            this.spread = new FarPoint.Win.Spread.FpSpread();
            this.sheetView = new FarPoint.Win.Spread.SheetView();
            this.secondSheetView = new FarPoint.Win.Spread.SheetView();
            this.pnlMain.SuspendLayout();
            this.pnlControls.SuspendLayout();
            this.gridLinesGroupBox.SuspendLayout();
            this.textRotationGroupBox.SuspendLayout();
            this.quickSettingGroupBox.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.spread)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.sheetView)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.secondSheetView)).BeginInit();
            this.SuspendLayout();
            // 
            // pnlMain
            // 
            this.pnlMain.Controls.Add(this.spread);
            this.pnlMain.Size = new System.Drawing.Size(481, 611);
            // 
            // pnlControls
            // 
            this.pnlControls.AutoScroll = true;
            this.pnlControls.Controls.Add(this.gridLinesGroupBox);
            this.pnlControls.Controls.Add(this.setBorderButton);
            this.pnlControls.Controls.Add(this.textRotationGroupBox);
            this.pnlControls.Controls.Add(this.clearBorderButton);
            this.pnlControls.Controls.Add(this.quickSettingGroupBox);
            this.pnlControls.Size = new System.Drawing.Size(159, 611);
            // 
            // gridLinesGroupBox
            // 
            this.gridLinesGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.gridLinesGroupBox.Controls.Add(this.setGridLineButton);
            this.gridLinesGroupBox.Controls.Add(this.gridLineColorComboBox);
            this.gridLinesGroupBox.Controls.Add(this.gridLineColorLabel);
            this.gridLinesGroupBox.Controls.Add(this.gridLineCKB);
            this.gridLinesGroupBox.Location = new System.Drawing.Point(16, 422);
            this.gridLinesGroupBox.Name = "gridLinesGroupBox";
            this.gridLinesGroupBox.Size = new System.Drawing.Size(136, 171);
            this.gridLinesGroupBox.TabIndex = 4;
            this.gridLinesGroupBox.TabStop = false;
            this.gridLinesGroupBox.Text = "GridLines";
            // 
            // setGridLineButton
            // 
            this.setGridLineButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.setGridLineButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            this.setGridLineButton.Location = new System.Drawing.Point(16, 127);
            this.setGridLineButton.Name = "setGridLineButton";
            this.setGridLineButton.Size = new System.Drawing.Size(101, 23);
            this.setGridLineButton.TabIndex = 3;
            this.setGridLineButton.Text = "Set GridLine";
            this.setGridLineButton.UseVisualStyleBackColor = true;
            this.setGridLineButton.Click += new System.EventHandler(this.SetGridLineButton_Click);
            // 
            // gridLineColorComboBox
            // 
            this.gridLineColorComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.gridLineColorComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.gridLineColorComboBox.FormattingEnabled = true;
            this.gridLineColorComboBox.Location = new System.Drawing.Point(16, 100);
            this.gridLineColorComboBox.Name = "gridLineColorComboBox";
            this.gridLineColorComboBox.Size = new System.Drawing.Size(101, 21);
            this.gridLineColorComboBox.TabIndex = 2;
            // 
            // gridLineColorLabel
            // 
            this.gridLineColorLabel.AutoSize = true;
            this.gridLineColorLabel.Location = new System.Drawing.Point(15, 74);
            this.gridLineColorLabel.Name = "gridLineColorLabel";
            this.gridLineColorLabel.Size = new System.Drawing.Size(76, 13);
            this.gridLineColorLabel.TabIndex = 1;
            this.gridLineColorLabel.Text = "GridLine Color:";
            // 
            // gridLineCKB
            // 
            this.gridLineCKB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.gridLineCKB.Location = new System.Drawing.Point(13, 20);
            this.gridLineCKB.Name = "gridLineCKB";
            this.gridLineCKB.Size = new System.Drawing.Size(104, 51);
            this.gridLineCKB.TabIndex = 0;
            this.gridLineCKB.Text = "GridLine Visible";
            this.gridLineCKB.UseVisualStyleBackColor = true;
            // 
            // textRotationGroupBox
            // 
            this.textRotationGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.textRotationGroupBox.Controls.Add(this.textRotationComboBox);
            this.textRotationGroupBox.Controls.Add(this.textRotationLabel);
            this.textRotationGroupBox.Controls.Add(this.diagonalLineCKB);
            this.textRotationGroupBox.Location = new System.Drawing.Point(16, 242);
            this.textRotationGroupBox.Name = "textRotationGroupBox";
            this.textRotationGroupBox.Size = new System.Drawing.Size(136, 160);
            this.textRotationGroupBox.TabIndex = 3;
            this.textRotationGroupBox.TabStop = false;
            this.textRotationGroupBox.Text = "Diagonal Line and Text Rotation";
            // 
            // textRotationComboBox
            // 
            this.textRotationComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.textRotationComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.textRotationComboBox.FormattingEnabled = true;
            this.textRotationComboBox.Location = new System.Drawing.Point(13, 133);
            this.textRotationComboBox.Name = "textRotationComboBox";
            this.textRotationComboBox.Size = new System.Drawing.Size(104, 21);
            this.textRotationComboBox.TabIndex = 2;
            this.textRotationComboBox.SelectedIndexChanged += new System.EventHandler(this.TextRotationComboBox_SelectedIndexChanged);
            // 
            // textRotationLabel
            // 
            this.textRotationLabel.AutoSize = true;
            this.textRotationLabel.Location = new System.Drawing.Point(10, 105);
            this.textRotationLabel.Name = "textRotationLabel";
            this.textRotationLabel.Size = new System.Drawing.Size(71, 13);
            this.textRotationLabel.TabIndex = 1;
            this.textRotationLabel.Text = "Text Rotation";
            // 
            // diagonalLineCKB
            // 
            this.diagonalLineCKB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.diagonalLineCKB.Location = new System.Drawing.Point(6, 38);
            this.diagonalLineCKB.Name = "diagonalLineCKB";
            this.diagonalLineCKB.Size = new System.Drawing.Size(111, 64);
            this.diagonalLineCKB.TabIndex = 0;
            this.diagonalLineCKB.Text = "Enable diagonal line";
            this.diagonalLineCKB.UseVisualStyleBackColor = true;
            this.diagonalLineCKB.CheckedChanged += new System.EventHandler(this.DiagonalLineCKB_CheckedChanged);
            // 
            // quickSettingGroupBox
            // 
            this.quickSettingGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.quickSettingGroupBox.Controls.Add(this.setButton);
            this.quickSettingGroupBox.Controls.Add(this.borderColorComboBox);
            this.quickSettingGroupBox.Controls.Add(this.borderColorLabel);
            this.quickSettingGroupBox.Controls.Add(this.borderStyleComboBox);
            this.quickSettingGroupBox.Controls.Add(this.borderStyleLabel);
            this.quickSettingGroupBox.Location = new System.Drawing.Point(16, 61);
            this.quickSettingGroupBox.Name = "quickSettingGroupBox";
            this.quickSettingGroupBox.Size = new System.Drawing.Size(136, 163);
            this.quickSettingGroupBox.TabIndex = 2;
            this.quickSettingGroupBox.TabStop = false;
            this.quickSettingGroupBox.Text = "Quick Setting";
            // 
            // setButton
            // 
            this.setButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.setButton.Location = new System.Drawing.Point(13, 134);
            this.setButton.Name = "setButton";
            this.setButton.Size = new System.Drawing.Size(104, 23);
            this.setButton.TabIndex = 4;
            this.setButton.Text = "Set";
            this.setButton.UseVisualStyleBackColor = true;
            this.setButton.Click += new System.EventHandler(this.SetButton_Click);
            // 
            // borderColorComboBox
            // 
            this.borderColorComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.borderColorComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.borderColorComboBox.FormattingEnabled = true;
            this.borderColorComboBox.Location = new System.Drawing.Point(13, 96);
            this.borderColorComboBox.Name = "borderColorComboBox";
            this.borderColorComboBox.Size = new System.Drawing.Size(104, 21);
            this.borderColorComboBox.TabIndex = 3;
            // 
            // borderColorLabel
            // 
            this.borderColorLabel.AutoSize = true;
            this.borderColorLabel.Location = new System.Drawing.Point(10, 79);
            this.borderColorLabel.Name = "borderColorLabel";
            this.borderColorLabel.Size = new System.Drawing.Size(68, 13);
            this.borderColorLabel.TabIndex = 2;
            this.borderColorLabel.Text = "Border Color:";
            // 
            // borderStyleComboBox
            // 
            this.borderStyleComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.borderStyleComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.borderStyleComboBox.FormattingEnabled = true;
            this.borderStyleComboBox.Location = new System.Drawing.Point(10, 37);
            this.borderStyleComboBox.Name = "borderStyleComboBox";
            this.borderStyleComboBox.Size = new System.Drawing.Size(107, 21);
            this.borderStyleComboBox.TabIndex = 1;
            // 
            // borderStyleLabel
            // 
            this.borderStyleLabel.AutoSize = true;
            this.borderStyleLabel.Location = new System.Drawing.Point(7, 20);
            this.borderStyleLabel.Name = "borderStyleLabel";
            this.borderStyleLabel.Size = new System.Drawing.Size(67, 13);
            this.borderStyleLabel.TabIndex = 0;
            this.borderStyleLabel.Text = "Border Style:";
            // 
            // clearBorderButton
            // 
            this.clearBorderButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.clearBorderButton.Location = new System.Drawing.Point(16, 32);
            this.clearBorderButton.Name = "clearBorderButton";
            this.clearBorderButton.Size = new System.Drawing.Size(136, 23);
            this.clearBorderButton.TabIndex = 1;
            this.clearBorderButton.Text = "Clear Border";
            this.clearBorderButton.UseVisualStyleBackColor = true;
            this.clearBorderButton.Click += new System.EventHandler(this.ClearBorderButton_Click);
            // 
            // setBorderButton
            // 
            this.setBorderButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.setBorderButton.Location = new System.Drawing.Point(16, 3);
            this.setBorderButton.Name = "setBorderButton";
            this.setBorderButton.Size = new System.Drawing.Size(136, 23);
            this.setBorderButton.TabIndex = 0;
            this.setBorderButton.Text = "Set Border";
            this.setBorderButton.UseVisualStyleBackColor = true;
            this.setBorderButton.Click += new System.EventHandler(this.SetBorderButton_Click);
            // 
            // spread
            // 
            this.spread.Dock = System.Windows.Forms.DockStyle.Fill;
            this.spread.Location = new System.Drawing.Point(0, 0);
            this.spread.Name = "spread";
            this.spread.Sheets.AddRange(new FarPoint.Win.Spread.SheetView[] {
            this.sheetView,
            this.secondSheetView});
            this.spread.Size = new System.Drawing.Size(481, 611);
            this.spread.TabIndex = 0;
            this.spread.ActiveSheetChanged += new System.EventHandler(this.Spread_ActiveSheetChanged);
            this.spread.ActiveSheetIndex = 1;
            // 
            // sheetView
            // 
            this.sheetView.Reset();
            this.sheetView.SheetName = "Basic border";
            // Formulas and custom names must be loaded with R1C1 reference style
            this.sheetView.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1;
            this.sheetView.EnableDiagonalLine = true;
            this.sheetView.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1;
            // 
            // secondSheetView
            // 
            this.secondSheetView.Reset();
            this.secondSheetView.SheetName = "Advanced Border";
            // Formulas and custom names must be loaded with R1C1 reference style
            this.secondSheetView.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1;
            this.secondSheetView.EnableDiagonalLine = true;
            this.secondSheetView.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1;
            // 
            // BordersDemo
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Name = "BordersDemo";
            this.Size = new System.Drawing.Size(641, 611);
            this.pnlMain.ResumeLayout(false);
            this.pnlControls.ResumeLayout(false);
            this.gridLinesGroupBox.ResumeLayout(false);
            this.gridLinesGroupBox.PerformLayout();
            this.textRotationGroupBox.ResumeLayout(false);
            this.textRotationGroupBox.PerformLayout();
            this.quickSettingGroupBox.ResumeLayout(false);
            this.quickSettingGroupBox.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.spread)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.sheetView)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.secondSheetView)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion
        private System.Windows.Forms.Button setBorderButton;
        private System.Windows.Forms.Button clearBorderButton;
        private System.Windows.Forms.GroupBox quickSettingGroupBox;
        private System.Windows.Forms.Button setButton;
        private System.Windows.Forms.ComboBox borderColorComboBox;
        private System.Windows.Forms.Label borderColorLabel;
        private System.Windows.Forms.ComboBox borderStyleComboBox;
        private System.Windows.Forms.Label borderStyleLabel;
        private System.Windows.Forms.GroupBox textRotationGroupBox;
        private System.Windows.Forms.ComboBox textRotationComboBox;
        private System.Windows.Forms.Label textRotationLabel;
        private System.Windows.Forms.CheckBox diagonalLineCKB;
        private System.Windows.Forms.GroupBox gridLinesGroupBox;
        private System.Windows.Forms.ComboBox gridLineColorComboBox;
        private System.Windows.Forms.Label gridLineColorLabel;
        private System.Windows.Forms.CheckBox gridLineCKB;
        private FpSpread spread;
        private SheetView sheetView;
        private System.Windows.Forms.Button setGridLineButton;
        private SheetView secondSheetView;
    }
}
